package com.lu.stack.nacos.controller;

import com.lu.stack.common.model.response.R;
import com.lu.stack.nacos.service.ArticleService;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author zhanglu
 * @project lu-cloud-stack
 * @description
 * @date 2023/1/30 17:01
 */
@RequestMapping("/test")
@RestController
public class TestController {

    @Resource
    private Environment env;
    @Resource
    private ArticleService articleService;

    @GetMapping("/t1")
    public Object t1(){
        return env.getProperty("application-message");
    }

    @GetMapping("/t2")
    public Object t2(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return articleService.list();
    }

    @GetMapping("/t5")
    public Object t5(){
        return R.success(env.getProperty("spring.application.name") + env.getProperty("server.port"));
    }


}
